package com.cddx.logistics.service.impl;

import com.cddx.logistics.domain.dto.VehicleTaskQueryDTO;
import com.cddx.logistics.domain.pojo.VehicleTask;
import com.cddx.logistics.domain.vo.VehicleTaskVO;
import com.cddx.logistics.mapper.VehicleTaskMapper;
import com.cddx.logistics.service.VehicleTaskService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class VehicleTaskServiceImpl implements VehicleTaskService {
    @Resource
    private VehicleTaskMapper vehicleTaskMapper;

    @Override
    public List<VehicleTaskVO> queryByDate(VehicleTaskQueryDTO queryDTO) {
        return vehicleTaskMapper.queryByDate(queryDTO);
    }

    @Override
    public PageInfo<VehicleTaskVO> queryPage(VehicleTaskQueryDTO queryDTO) {
        PageHelper.startPage(queryDTO.getPage(), queryDTO.getLimit());
        List<VehicleTaskVO> list = vehicleTaskMapper.queryPage(queryDTO);
        return new PageInfo<>(list);
    }

    @Override
    public boolean add(VehicleTask vehicleTask) {
        return vehicleTaskMapper.add(vehicleTask) > 0;
    }

    @Override
    public boolean update(VehicleTask vehicleTask) {
        return vehicleTaskMapper.update(vehicleTask) > 0;
    }

    @Override
    public boolean delete(Integer id) {
        return vehicleTaskMapper.delete(id) > 0;
    }
}